package com.dgut.common.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dgut.common.entity.WxUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zyq
 * @since 2022-03-13
 */
@Repository
public interface WxUserMapper extends BaseMapper<WxUser> {

    @Update("update wx_user set identity = #{identity} where id = #{id}")
    void updateIdentityById(@Param("identity") Integer identity, @Param("id") Integer id);

    @Update("update wx_user set cur_money = cur_money - #{amount} where id = #{id}")
    void updateCurMoney(Integer amount, Integer id);

    @Update("update wx_user set all_money = all_money + #{amount} where id = #{id}")
    void updateAllMoney(Integer amount, Integer id);

    @Update("update wx_user set all_money = all_money + #{amount}, cur_money = cur_money + #{amount} where id = #{id}")
    void updateMoney(Integer amount, Integer id);

    IPage<WxUser> selectPageByCondition(IPage<WxUser> page, String name, Integer identity);

}
